home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / patches / pgs3f.lha / 3.0fUpdate / Macros.LHA / PrintMacros.rexx < prev    next >
OS/2 REXX Batch file  |  1994-09-25  |  4KB  |  120 lines

  1. /* $VER: PrintMacros.rexx 1.0 (02.25.94)
  2.    Copyright 1994 Soft-Logik Publishing Corporation
  3.    May not be distributed without Soft-Logik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. ADDRESS 'PAGESTREAM'
  7.  
  8. /* Make sure rexx support is opened */
  9. if ~show('L','rexxsupport.library') then
  10.     call addlib('rexxsupport.library',0,-30)
  11.  
  12. /* GIVE INSTRUCTIONS */
  13. allocarexxrequester '"Print Macro Documentation"' 544 101
  14.     reqhandle=result
  15. addarexxgadget reqhandle EXIT 12 84 70 label "_Ok"
  16.     Okhandle=result
  17. addarexxgadget reqhandle EXIT 462 84 70 label "_Cancel"
  18.     Cancelhandle=result
  19. addarexxgadget reqhandle TEXT 8 10 528 border none string "'This macro will create a printed copy of the PageStream macro'"
  20. addarexxgadget reqhandle TEXT 8 20 528 border none string "'documentation. This information is provided only in help system,'"
  21. addarexxgadget reqhandle TEXT 8 30 528 border none string "'but this macro will print it to your Preference compatible'"
  22. addarexxgadget reqhandle TEXT 8 40 528 border none string "'printer. You must select a printer driver with Sys:Prefs/Printer'"
  23. addarexxgadget reqhandle TEXT 8 50 528 border none string "'before using this macro. Each macro will be printed on a separate'"
  24. addarexxgadget reqhandle TEXT 8 60 528 border none string "'page and there are over 300 macros.'"
  25. doarexxrequester reqhandle
  26.  
  27. action=result
  28. freearexxrequester reqhandle
  29. if action=cancelhandle then exit
  30.  
  31. /* MAIN LOOP */
  32. page=1
  33. do i=1 to 7
  34.     ifilename='PageStream3:Help/PGS.MD'||i
  35.     ofilename='ram:PGS.MD'||i
  36.     say 'Processing 'ifilename'...'
  37.     if ~open(.ifile, ifilename, 'R') then return 9
  38.     if ~open(.ofile, ofilename, 'W') then return 8
  39.     do ii=1 to 14
  40.         call readln(.ifile)
  41.     end ii
  42.     do until eof(.ifile)
  43.         currentline=readln(.ifile)
  44.         check=left(currentline,4)
  45.         midcheck=substr(currentline,5,9)
  46.         select
  47.             when check="@nod" then do
  48.                 parse var currentline dum nodename .
  49.                 index.page=nodename
  50.                 call readln(.ifile)
  51.                 call writeln(.ofile, '- '||page||' -')
  52.                 call writeln(.ofile, "")
  53.                 page=page+1
  54.                 end
  55.             when check='@toc' | check='@nex' | check='@pre' | midcheck='Command F' | midcheck='Object ID' | midcheck='DOCUMENT,' then nop
  56.             when check='@end' then do
  57.                 call readln(.ifile)
  58.                 call writeln(.ofile, d2c(12))
  59.                 end
  60.             otherwise do
  61.                 call search()
  62.                 call writeln(.ofile, currentline)
  63.                 end
  64.         end
  65.     end
  66.     call close(.ifile)
  67.     call close(.ofile)
  68. end i
  69.  
  70. /* INDEX */
  71. say 'Generating Index'
  72. if ~open(.ofile, 'ram:Macro.Index', 'W') then return 8
  73. call writeln(.ofile, 'Macro Index')
  74. do i=1 to page-1
  75.     call writeln(.ofile, right(i,3)||'...'||index.i)
  76. end
  77. call close(.ofile)
  78.  
  79. /* PRINT FILES */
  80. do i=1 to 7
  81.     say 'Printing File 'i' of 8'
  82.     address command 'copy ram:PGS.MD'i' PRT:'
  83.     address command 'delete ram:PGS.MD'i' to PRT:'
  84. end i
  85. address command 'copy ram:Macro.Index PRT:'
  86. address command 'delete ram:Macro.Index'
  87.  
  88. EXIT
  89.  
  90.  
  91.  
  92. SEARCH:
  93. do count=1 until currentline=''
  94.     code=1
  95.     /* if there's an AmigaGuide code, find its position */
  96.     do while code ~= 0
  97.         code=pos('@{',currentline)
  98.         if code~=0 then do
  99.             type1=upper(substr(currentline,code,4))
  100.             type2=upper(substr(currentline,code,6))
  101.             if c2d(substr(currentline,code+2,1))=34 then do
  102.                 currentline=left(currentline,code-1)||right(currentline,length(currentline)-code-2)
  103.                 endnode=pos(d2c(34),currentline,code)
  104.                 endlink=pos('}',currentline,endnode)
  105.                 currentline=left(currentline,endnode-1)||right(currentline,length(currentline)-endlink)
  106.             end
  107.             else do
  108.                 select
  109.                     when type1='@{U}' | type1='@{B}' then chop=3
  110.                     when type1='@{UU' | type1='@{UB' then chop=4
  111.                     when type2='@{FG H' then chop=14
  112.                     when type2='@{FG T' then chop=9
  113.                     otherwise nop
  114.                 end
  115.                 currentline=left(currentline,code-1)||right(currentline,length(currentline)-code-chop)
  116.             end
  117.         end
  118.     end
  119. Return
  120.